<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	<title>选择入住时间和是否需要二装</title>
	<base href="<%=basePath%>"> 
	<link rel="stylesheet" href="css/bootstrap.css">
	
	 <link rel="stylesheet" href="css/vivo.css">
    <link rel="stylesheet" href="css/cmxform.css">
    <link rel="stylesheet" href="js/grid/bsgrid.all.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="js/Hui-iconfont/1.0.7/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="js/icheck/icheck.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
	<link rel="stylesheet" href="js/grid/bsgrid.all.min.css"/>

    
	
	<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
	<script src="js/select2/select2.min.js"></script>
	<script src="js/jquery-1.11.1.js"></script>
    <script src="js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
    <script src="js/jquery.validation/1.14.0/messages_zh.min.js"></script>
    <script type="text/javascript" src="js/layer/layer/layer.js"></script>
   	<script language="javascript" type="text/javascript" src="<%=basePath %>js/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="js/sharefunction.js"></script>
    <link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
	<script src="js/select2/select2.min.js"></script>
	<script type="text/javascript">
	
	$.validator.setDefaults({
		    submitHandler: function() {
		      	saveDocument();
		    }
		});
		
		$(document).ready(function() {
		$("#decoration").select2({minimumResultsForSearch:-1});
		    $("#commentForm").validate({
		    	errorPlacement: function(error, element) {
					// Append error within linked label
					$( element ).next().append( error );
				},
				errorElement: "span",
				messages: {
					typeName: {
						required: " 必需字段!",
						minlength: " (不能少于 3 个字母)"
					}
				}
				
		    });
		    formatDate();
			$("#checkinTime").blur(function(){
				var tip1 = $(this).val();
			    if(tip1==""){
			    	$("#tip2").html("");
			    }else{
			    	$("#tip2").html("（默认填写合同起止时间）");
			    }
			});
			
		});

		function formatDate(){
			$(".Wdate").each(function (){
				data = $(this).val();
				if(data==null||data==""){
					$(this).val("");
				}else{
					$(this).val(data.substring(0,10));
				}
			});
			
		}
		function bcc(){
			
		}
		
		function saveDocument(){
			var id = $("#id").val();
			var decoration=$("#decoration").val();
			var checkinTime=$("#checkinTime").val();
			var moveDate = $("#moveDate").val();
			var status=0;//在住
			//var customerId = "${customerId}";
			var roomId=$("#roomInfoId").val();
			var customerId=$("#customerId").val();
			checkinTime=checkinTime+" 00:00:00"
			moveDate=moveDate+" 00:00:00"
			//layer.confirm("确定保存吗？",{icon:3},function(i){
				var url = "customer/customerCheckin/update";
				jQuery.ajax({
				    type:"post",
				    async:false,
				    url:url,
			        dataType:"json",
			        data:{
			        	id:id,
			        	status:status,
			        	roomId:roomId,
						moveDate:moveDate,
						decoration:decoration,
						checkinTime:checkinTime,
						customerId:customerId
			        },
				    success:function(responseText){
				        if(responseText.success){
				        	window.parent.layer.msg('修改成功！');
				        	window.parent.gridObjCheckin.refreshPage();
				        	closeLayer();
		    			}else{
		    				layer.alert(responseText.msg, {icon: 7});
		    				//closeLayer();
		    			}
				    }
		   		});
				
			//});
		}
	
	</script>
	</head>
	<body>
		<form class="cmxform" id="commentForm" method="get" action="">
		<div style="padding:10px">
			<div class="panel panel-default" style="margin:10px 10px 10px 10px;">
			<div class="panel-heading">
      				<h5 class="panel-title">选择入住时间和是否需要二装</h5>
   			  	</div>
	   			<div class="panel-body">
			<table cellpadding="10" cellspacing="5" class="mytable">
				<tr>
					<td width="95px">续租的房间</td>
					<td >						
						<b>${roomInfo.roomNumber }</b>
					</td>
				</tr>
				<tr>
					<td width="95px">入住时间</td>
					<td >						
						<input type="text" width="90px" name="checkinTime" id="checkinTime" class="Wdate" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'moveDate\')}'})" required value="${customerCheckin.checkinTime }"/> <font color="red"> *</font> 
						<span id="tip1"></span><font id="tip2" color="red">（默认填写合同起止时间）</font>
					</td>
				</tr>
				<tr>
					<td width="95px">预计迁出时间</td>
					<td >						
						<input type="text" width="90px" name="moveDate" id="moveDate" class="Wdate" onclick="WdatePicker({minDate:'#F{$dp.$D(\'checkinTime\')}'})"  required  value="${customerCheckin.moveDate }"/> <font color="red"> *</font> 
						<span></span>
					</td>
				</tr>
				<tr>
					<td width="95px">是否需要二装</td>
					<td>
						
						<select style="width:45px" id="decoration" name="decoration"  >
							<c:choose>
								<c:when test="${customerCheckin.decoration=='1'}">
									<option value="1" selected>否</option>
									<option value="0">是</option>
								</c:when>
								<c:when test="${customerCheckin.decoration=='0'}">
									<option value="1">否</option>
									<option value="0" selected>是</option>
								</c:when>
							</c:choose>
						</select>
					</td>
				</tr>
			</table>
				
			</div>
			</div>
			</div>
			<div style="width:100%;text-align:center; padding-top:20px"> 
				<button class="btn btn-primary radius" style="height:31px;width:58.16px;font-size:13px"type="submit" > 保 存</button> 
				 <a class="btn btn-default radius"  style="height:31px;width:58.16px;font-size:13px" onClick="closeLayer();"> 取 消 </a> 
		    	  <br/><br/>
	    	</div> 
	    	<div style="display:none">
	    	<input type="text" name="roomInfoId" id="roomInfoId" value="${roomInfo.id }">
	    	<input type="text" name="customerId" id="customerId" value="${customerCheckin.customerInfo.id }">
	    	<input type="text" name="id" id="id" value="${customerCheckin.id }">
	    </div>
	    
		</form>
  	</body>
  	
   </html>
  	

	
	

